package com.neuronbit.businessflow.flow.source;

import com.neuronbit.businessflow.flow.source.util.SourceContext;
import com.neuronbit.businessflow.intellij.model.Node;
import com.neuronbit.businessflow.runtime.StartStep;
import com.neuronbit.businessflow.runtime.StepType;
import com.neuronbit.javaparser.ast.stmt.BlockStmt;

import static java.lang.String.format;


/**
 * The type Start step java source.
 */
public class StartStepJavaSource extends StepJavaSource implements FLowEntryStep {

    /**
     * Instantiates a new Start step java source.
     *
     * @param node          the node
     * @param sourceContext the source context
     */
    public StartStepJavaSource(Node node, SourceContext sourceContext) {
        super(node, sourceContext);
    }

    public String getEntryStmt() {
        return format("new %s().call(context, this);", getStepClass().getNameAsString());
    }

    @Override
    protected void addExtendedType() {
        getStepClass().addExtendedType(format("com.neuronbit.businessflow.runtime.StartStep<%s>", getContextSource().getSimpleName()));
    }

    @Override
    protected StepType getStepType() {
        return StepType.START;
    }

    @Override
    protected void writeStepCallStmt(BlockStmt stepCallStmt) {
    }

}
